package com.bobo.web.api.vo.base;

import java.io.Serializable;
import java.util.List;

public class PageBase<T> implements Serializable {
    private static final long serialVersionUID = -4314933610918212404L;

    private List<T> list;//数据列表

    private long totalSize;//数据总量
    private int pageNo; //当前页码 从第一页开始
    private int pageSize;//每页数据行数
    private int totalPage;//总页码数
    private long count;//数据总量

    public PageBase() {

    }

    public PageBase(List<T> list, long totalSize, int pageNo, int pageSize) {
        this.list = list;
        this.totalSize = totalSize;
        this.pageSize = pageSize;
        this.pageNo = pageNo;

        this.totalPage = (int) ((totalSize - 1) / pageSize + 1);
    }

    public PageBase(long count, List<T> list) {
        this.count = count;
        this.list = list;
    }


    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPageNo) {
        this.totalPage = totalPageNo;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("DataPage{");
        sb.append("list=").append(list);
        sb.append(", totalSize=").append(totalSize);
        sb.append(", pageSize=").append(pageSize);
        sb.append(", pageNo=").append(pageNo);
        sb.append(", totalPageNo=").append(totalPage);
        sb.append('}');
        return sb.toString();
    }

}
